package org.perla.entities;

import java.io.Serializable;
import javax.persistence.Basic;
import javax.persistence.Column;
import javax.persistence.EmbeddedId;
import javax.persistence.Entity;
import javax.persistence.Lob;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.Table;

/**
 *
 */
@Entity
@Table(name = "bibi")
@NamedQueries({
    @NamedQuery(name = "Bibi.findAll", query = "SELECT b FROM Bibi b"),
    @NamedQuery(name = "Bibi.findByIdSensore", query = "SELECT b FROM Bibi b WHERE b.bibiPK.idSensore = :idSensore"),
    @NamedQuery(name = "Bibi.findByTimestamp", query = "SELECT b FROM Bibi b WHERE b.bibiPK.timestamp = :timestamp"),
    @NamedQuery(name = "Bibi.findByFlags", query = "SELECT b FROM Bibi b WHERE b.flags = :flags"),
    @NamedQuery(name = "Bibi.findBySamples", query = "SELECT b FROM Bibi b WHERE b.samples = :samples"),
    @NamedQuery(name = "Bibi.findByMagnitudex", query = "SELECT b FROM Bibi b WHERE b.magnitudex = :magnitudex"),
    @NamedQuery(name = "Bibi.findByMagnitudey", query = "SELECT b FROM Bibi b WHERE b.magnitudey = :magnitudey"),
    @NamedQuery(name = "Bibi.findByMagnitudez", query = "SELECT b FROM Bibi b WHERE b.magnitudez = :magnitudez"),
    @NamedQuery(name = "Bibi.findByPeakx", query = "SELECT b FROM Bibi b WHERE b.peakx = :peakx"),
    @NamedQuery(name = "Bibi.findByPeaky", query = "SELECT b FROM Bibi b WHERE b.peaky = :peaky"),
    @NamedQuery(name = "Bibi.findByPeakz", query = "SELECT b FROM Bibi b WHERE b.peakz = :peakz"),
    @NamedQuery(name = "Bibi.findByNoisex", query = "SELECT b FROM Bibi b WHERE b.noisex = :noisex"),
    @NamedQuery(name = "Bibi.findByNoisey", query = "SELECT b FROM Bibi b WHERE b.noisey = :noisey"),
    @NamedQuery(name = "Bibi.findByNoisez", query = "SELECT b FROM Bibi b WHERE b.noisez = :noisez"),
    @NamedQuery(name = "Bibi.findBySamplingTimestamp", query = "SELECT b FROM Bibi b WHERE b.samplingTimestamp = :samplingTimestamp"),
    @NamedQuery(name = "Bibi.findByIdNodo", query = "SELECT b FROM Bibi b WHERE b.bibiPK.idNodo = :idNodo")})
public class Bibi implements Serializable {
    private static final long serialVersionUID = 1L;
    @EmbeddedId
    protected BibiPK bibiPK;
    @Basic(optional = false)
    @Lob
    @Column(name = "DATA")
    private byte[] data;
    @Basic(optional = false)
    @Column(name = "FLAGS")
    private short flags;
    @Basic(optional = false)
    @Column(name = "SAMPLES")
    private short samples;
    @Basic(optional = false)
    @Column(name = "MAGNITUDEX")
    private int magnitudex;
    @Basic(optional = false)
    @Column(name = "MAGNITUDEY")
    private int magnitudey;
    @Basic(optional = false)
    @Column(name = "MAGNITUDEZ")
    private int magnitudez;
    @Basic(optional = false)
    @Column(name = "PEAKX")
    private short peakx;
    @Basic(optional = false)
    @Column(name = "PEAKY")
    private short peaky;
    @Basic(optional = false)
    @Column(name = "PEAKZ")
    private short peakz;
    @Basic(optional = false)
    @Column(name = "NOISEX")
    private short noisex;
    @Basic(optional = false)
    @Column(name = "NOISEY")
    private short noisey;
    @Basic(optional = false)
    @Column(name = "NOISEZ")
    private short noisez;
    @Basic(optional = false)
    @Column(name = "sampling_timestamp")
    private long samplingTimestamp;

    public Bibi() {
    }

    public Bibi(BibiPK bibiPK) {
        this.bibiPK = bibiPK;
    }

    public Bibi(BibiPK bibiPK, byte[] data, short flags, short samples, int magnitudex, int magnitudey, int magnitudez, short peakx, short peaky, short peakz, short noisex, short noisey, short noisez, long samplingTimestamp) {
        this.bibiPK = bibiPK;
        this.data = data;
        this.flags = flags;
        this.samples = samples;
        this.magnitudex = magnitudex;
        this.magnitudey = magnitudey;
        this.magnitudez = magnitudez;
        this.peakx = peakx;
        this.peaky = peaky;
        this.peakz = peakz;
        this.noisex = noisex;
        this.noisey = noisey;
        this.noisez = noisez;
        this.samplingTimestamp = samplingTimestamp;
    }

    public Bibi(String idSensore, long timestamp, String idNodo) {
        this.bibiPK = new BibiPK(idSensore, timestamp, idNodo);
    }

    public BibiPK getBibiPK() {
        return bibiPK;
    }

    public void setBibiPK(BibiPK bibiPK) {
        this.bibiPK = bibiPK;
    }

    public byte[] getData() {
        return data;
    }

    public void setData(byte[] data) {
        this.data = data;
    }

    public short getFlags() {
        return flags;
    }

    public void setFlags(short flags) {
        this.flags = flags;
    }

    public short getSamples() {
        return samples;
    }

    public void setSamples(short samples) {
        this.samples = samples;
    }

    public int getMagnitudex() {
        return magnitudex;
    }

    public void setMagnitudex(int magnitudex) {
        this.magnitudex = magnitudex;
    }

    public int getMagnitudey() {
        return magnitudey;
    }

    public void setMagnitudey(int magnitudey) {
        this.magnitudey = magnitudey;
    }

    public int getMagnitudez() {
        return magnitudez;
    }

    public void setMagnitudez(int magnitudez) {
        this.magnitudez = magnitudez;
    }

    public short getPeakx() {
        return peakx;
    }

    public void setPeakx(short peakx) {
        this.peakx = peakx;
    }

    public short getPeaky() {
        return peaky;
    }

    public void setPeaky(short peaky) {
        this.peaky = peaky;
    }

    public short getPeakz() {
        return peakz;
    }

    public void setPeakz(short peakz) {
        this.peakz = peakz;
    }

    public short getNoisex() {
        return noisex;
    }

    public void setNoisex(short noisex) {
        this.noisex = noisex;
    }

    public short getNoisey() {
        return noisey;
    }

    public void setNoisey(short noisey) {
        this.noisey = noisey;
    }

    public short getNoisez() {
        return noisez;
    }

    public void setNoisez(short noisez) {
        this.noisez = noisez;
    }

    public long getSamplingTimestamp() {
        return samplingTimestamp;
    }

    public void setSamplingTimestamp(long samplingTimestamp) {
        this.samplingTimestamp = samplingTimestamp;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (bibiPK != null ? bibiPK.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof Bibi)) {
            return false;
        }
        Bibi other = (Bibi) object;
        if ((this.bibiPK == null && other.bibiPK != null) || (this.bibiPK != null && !this.bibiPK.equals(other.bibiPK))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "org.perla.entities.Bibi[bibiPK=" + bibiPK + "]";
    }

}
